package com.nefu.editor.core.mapper;

import com.nefu.editor.core.mapper.provider.UserProvider;
import com.nefu.editor.core.model.Article;
import com.nefu.editor.core.model.User;
import com.nefu.editor.core.model.Vo.UserVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author chenchenT
 * @date : 18-11-12
 * @since : java 8
 */
@Mapper
@Repository
public interface UserMapper {

    /**
     * 根据条件查询用户
     *
     * @param user
     * @return
     */
    @SelectProvider(type = UserProvider.class, method = "selectUserByCondition")
    List<User> selectUserByCondition(User user);

    /**
     * 设置token
     *
     * @param user
     * @return
     */
    @Update("update t_user set user_token=#{token} where user_systemId=#{systemId}")
    int updateTokenBySystemId(User user);

    /**
     * 根据用户ID查询
     *
     * @param user 主键
     * @return 符合条件的记录
     */
    @SelectProvider(type = UserProvider.class, method = "selectByUserSystemId")
    List<User> selectByUserSystemId(UserVo user);

    /**
     * 根据用户ID修改 password
     *
     * @param user 参数集
     * @return 更新记录数
     */
    @Update("UPDATE t_user SET user_password=#{password} WHERE user_systemId=#{systemId}")
    int updatePassWordByUserSystemId(User user);

    /**
     * 增加新用户
     *
     * @param user
     * @return
     */
    @InsertProvider(type = UserProvider.class, method = "insertNewUser")
    int insertNewUser(User user);

}
